package com.milk.service.user;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;

import com.milk.model.entity.user.User;
import com.milk.service.user.dao.UserDao;

import org.springframework.stereotype.Service;


/**
 * user serviceImpl
 * 2017-09-14 16:57:16  徐政涛
 */ 
@Service("userService")
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;
    
    public User save(User user) {
        Assert.notNull(user, RESULT_NULL+"出错的方法体是saveUser");
        userDao.save(user);
        return user;
    }
    public User update(User user) throws Exception {
        Assert.notNull(user, RESULT_NULL+"出错的方法体是updateUser");
        userDao.update(user);
        return user;
    }
    public User getUserById(long userId) {
        User user = userDao.findById(userId);
        return user;
    }
    public void deleteUserById(long userId) {
        userDao.deleteById(userId);
    }
    public User getUserByMap(Map<String, Object> params) {
        User user = userDao.findByMap(params);
        return user;
    }
    public void deleteUserByMap(Map<String, Object> params) {
        userDao.deleteByMap(params);
    }
    public List<User> queryUser(Map<String, Object> params) {
        List<User> users = userDao.query(params);
        return users;
    }
}